    // import React from 'react';
    // import http from '../../utils/http';
    // import './css/address.less';
    // let staticState = [];
    // class Address extends React.Component {
    //     state={
    //         valueInfo:'',
    //         valueObj:[]
    //     }
    //     findCity(){
    //         http
    //             .get('/city/findCity')
    //             .then(data => { 
    //                 this.setState({
    //                     valueObj:data
    //                 })
    //             }, err => {
    //         })
    //     }
    //     componentDidMount(){
    //         this.findCity();
    //     }
    //   render () {
    //     return (
    //         <div className="form-group">
    //             <label htmlFor="exampleInputName2">城市</label>
    //             <input type="text" className="form-control" id="exampleInputName2" placeholder="地址" onChange={(e)=>{
    //                 this.state.valueObj.map((item,i)=>{
    //                     if(e.target.value!='' && item.name.indexOf(e.target.value)>-1 && !staticState[item.name]){
    //                        staticState.push(item);
    //                     }
    //                 })
    //             }}/>
    //         </div>
    //     )
    //   }
    // }
    // export default Address



    import React from 'react';
    import http from '../../utils/http';
    import './css/address.less';

    let city={
        cityid:"",
        cityVosid:""
    }
    let propsID =''
    class Address extends React.Component {
        state={
            valueInfo:'',
            valueObj:['省份'],
            cityObj:['城市']
        }
        findCity(){
            http
                .get('/city/findCity')
                .then(data => { 
                    if(data){
                        data.unshift({id:0,name:'省份',cityVos:[{id:"0",name:"城市"}]});
                        this.setState({
                            valueObj:data||[{name:'省份'}],
                            cityObj:[{id:"0",name:"城市"}]
                        })
                        this.getCityID(propsID.cityid);
                    }
                }, err => {
            })
        }
        getCityID(e){
            console.log(this.props)
            console.log(this.state.valueObj)
            let digList = this.state.valueObj.find((x)=>{
                return Number(x.id) === Number(e)
            })
            console.log(digList)
            if(digList&&digList.cityVos&&digList.cityVos[0].name!=="城市"){
                digList.cityVos.unshift({id:"0",name:"城市"})
            }
            this.setState({
                cityObj:(digList&&digList.cityVos)||[{id:"0",name:"城市"}]
            })
            city.cityid = e;
        }
        componentWillMount(){
            this.findCity();
        }
        componentWillReceiveProps(nextProps){
            propsID = nextProps;
        }
    render () {
        return (
            <div className="form-group col-xs-12" style={{padding:0}}>
                <div className="inp-text">
                    <label htmlFor="exampleInputName2">城市</label>
                </div>
                <div className="border-sel">
                    <select value={this.props.cityid} style={{cursor:"pointer"}} className="intBorder" autoComplete="off" onChange={(e)=>{this.getCityID(e.target.value);this.props.getCity(city)}}>
                        {
                            this.state.valueObj.map((item,i) => (
                            <option key={`city${i}`} value={item.id}>{item.name}</option>
                            ))
                        }
                    </select>
                </div>
                <div className="border-sel">
                    <select value={this.props.provinceid} style={{cursor:"pointer"}} className="intBorder" autoComplete="off" onChange={(e)=>{
                        city.cityVosid = e.target.value;
                        this.props.getCity(city);
                    }}>
                        {
                            this.state.cityObj.map((item,i) => (
                            <option key={`city${i}`} value={item.id}>{item.name}</option>
                            ))
                        }
                    </select>
                </div>
            </div>
        )
    }
    }
    export default Address